<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>答题闯关王</title>
    <link rel="shortcut icon" href="__STATIC__/favicon.ico"/>
    <link href="__STATIC__/css/index/index.css" type="text/css" rel="stylesheet">
	<link href="__STATIC__/layui/css/layui.css" type="text/css" rel="stylesheet">
	<link href="__STATIC__/bootstrap-3.3.7/css/bootstrap.min.css" type="text/css" rel="stylesheet">
    <link href="__STATIC__/css/index/iconfont/iconfont.css" type="text/css" rel="stylesheet">
	<script src="__STATIC__/layui/layui.all.js" type="application/javascript"></script>
	<style>
		.desktop .order-box table tbody tr td{
			text-align: center;
		}
		.layui-input{
			width: 30%;
			height: 30px;
		}
		.layui-form-label{
			padding-top: 4px;
		}
		.layui-input, .layui-textarea {
			display: none !important;
			}
	</style>
</head>
<body>
	<div class="desktop item-wrapper">
		<div class="desktop-main">
			<div class="order-box">
				<div class="layui-form-item">
					<button type="button" class="layui-btn layui-btn-sm" onclick="add()" style="float: right;margin-right: 10px; margin-top: 3px;" >
						<i class="layui-icon">&#xe608;</i> 添加
					</button>
				</div>
				<table cellspacing="0" ng-show="docArr.length>0">
					<thead>
						<tr>	
							<td>id</td>
							<td>题目</td>
							<td>答案选项</td>
							<td>正确答案</td>
							<td>题目分值</td>
							<td>操作</td>
						</tr>
					</thead>
					<tbody class="order-table">
					{volist name="arra" id="Tmanagement"}
						<tr id="addForm">
							<td>{$Tmanagement['id']}</td>
							<td>{$Tmanagement['subject']}</td>
							<td>{$Tmanagement['optional']}</td>
							<td>{$Tmanagement['answer']}</td>
							<td>{$Tmanagement['score']}</td>
							<td>
								<div class="layui-btn-group">
									<a href="javascript:;" class="update" onclick="update('{$Tmanagement["id"]}')">
										<i class="layui-icon">&#xe642;</i>
									</a>
									<a href="javascript:;" class="del" onclick="del('{$Tmanagement["id"]}')">
										<i class="layui-icon">&#xe640;</i>
									</a>
								</div>
							</td>
						</tr>
					{/volist}
					</tbody>
				</table>
				<div style="text-align: center">
					<div id="test1"></div>
				</div>
			</div>
		</div>
	</div>
</body>
<script src="__STATIC__/js/jquery-3.3.1.js" type="application/javascript"></script>
<script src="__STATIC__/js/maowenke.js" type="application/javascript"></script>
<script>
    layui.use('laypage', function(){
        var laypage = layui.laypage;

        //执行一个laypage实例
        laypage.render({
            elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
            ,count: parseInt('{$shu}') //数据总数，从服务端得到
			,limit:10
			,jump:function (obj,first) {
				if(!first){
				    $.post('{:url("page/topic")}',{page:obj.curr,limit:10},function (data) {
						$("tbody").empty();
						var str = '';
						$.each(data,function (i,v) {
							str+='<tr id="addForm">'+
                            '<td>'+v.id+'</td>'+
                            '<td>'+tostr(v.subject)+'</td>'+
                            '<td>'+tostr(v.optional)+'</td>'+
                            '<td>'+tostr(v.answer)+'</td>'+
                            '<td>'+tostr(v.score)+'</td>'+
                            '<td>'+
                            '<div class="layui-btn-group">'+
                            '<a href="javascript:;" class="update" onclick="update('+v.id+')">'+
                            '<i class="layui-icon">&#xe642;</i>'+
                            '</a>'+
                            '<a href="javascript:;" class="del" onclick="del('+v.id+')">'+
                            '<i class="layui-icon">&#xe640;</i>'+
                            '</a>'+
                            '</div>'+
                            '</td>'+
                            '</tr>';
                        })
						$("tbody").append(str);
                    });
				}
            }
        });
    });
	//添加题目
	function add(){
        	layer.closeAll();
			layer.open({
				type: 2,
				title: '添加题目',
				shadeClose: true,
				shade: false,
				maxmin: true, //开启最大化最小化按钮
				area: ['893px', '600px'],
				content: "{:url('form/add')}"

			});
	}
	//更新题目
	function update($id){
        layer.closeAll();
        layer.open({
            type: 2,
            title: '更新题目',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['893px', '600px'],
            content: "{:url('form/update')}?id="+$id
        });
	}
	//删除题目
    function del($id) {
        layer.confirm('您确定要删除该信息吗？', {
            btn: ['确定','取消'] //按钮
        	},
			function(){
            $.post("/index/form/dels",{id:$id},function (datas) {
                if (datas = 1) {
                    layer.msg('删除成功',{icon:1,time:2000});
                    refreshParent();
                }else{
                    layer.msg('删除失败',{icon:1,time:2000});
                }
            	})
			})
    }
    function refreshParent() {
        location.reload();
    }
	function dao(){
		document.getElementById("btn_file").click(
			function(){
				alert(123);
			}
		);
	}
</script>
</html>